package com.example.electricbicycle.service;

import com.example.electricbicycle.dao.CustomerDAO;
import com.example.electricbicycle.dao.CustomerDAOImpl;
import com.example.electricbicycle.po.Customer;
import com.example.electricbicycle.service.CustomerService;
import java.util.List;

public class CustomerServiceImpl implements CustomerService {
    private final CustomerDAO customerDao = new CustomerDAOImpl();

    @Override
    public int addCustomer(Customer customer) {
        return customerDao.addCustomer(customer);
    }

    @Override
    public int deleteCustomer(int customerId) {
        return customerDao.deleteCustomer(customerId);
    }

    @Override
    public int updateCustomer(Customer customer) {
        return customerDao.updateCustomer(customer);
    }

    @Override
    public Customer getCustomerById(int customerId) {
        return customerDao.findCustomerById(customerId);
    }

    @Override
    public List<Customer> getAllCustomers(int page, int pageSize) {
        int startIndex = (page - 1) * pageSize;
        return customerDao.findAllCustomers(startIndex, pageSize);
    }

    @Override
    public int getTotalCustomerCount() {
        return customerDao.getTotalCount();
    }

    @Override
    public List<Customer> searchCustomers(String keyword) {
        return customerDao.searchCustomers(keyword);
    }
}